﻿Shader "Custom/Curved" {
	
	Properties {
		_MainTex ("Base (RGB)", 2D) = "white" {}
		_QOffset ("Offset", Vector) = (0,0,0,0)
		_Brightness ("曝光度_Brightness", Float) = 0.0
		_Dist ("距离_Distance", Float) = 100.0
	}
	
	SubShader {
			Tags{ "RenderType" = "Opaque" }
			LOD 100
		Tags { "Queue" = "Transparent"}
		Pass
		{
			
	        Blend SrcAlpha OneMinusSrcAlpha 
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag
			#pragma multi_compile_fog
			#include "UnityCG.cginc"
			
			

            sampler2D _MainTex;
			float4 _QOffset;
			float _Dist;
			float _Brightness;
			
			struct v2f {
			    float4 pos : SV_POSITION;
			    float4 uv : TEXCOORD0;
			    float3 viewDir : TEXCOORD1;
			    UNITY_FOG_COORDS(2)
			    fixed4 color : COLOR;
			};

			v2f vert (appdata_full v)
			{
			   v2f o;
			   float4 vPos = mul (UNITY_MATRIX_MV, v.vertex);
			   float zOff = vPos.z/_Dist;
			   vPos += _QOffset*zOff*zOff;
			   o.pos = mul (UNITY_MATRIX_P, vPos);
			   o.uv = v.texcoord;
			   UNITY_TRANSFER_FOG(o,o.pos);
			   return o;
			}
			half4 frag (v2f i) : COLOR0
			{
			  	half4 col = tex2D(_MainTex, i.uv.xy);
			  	col *= UNITY_LIGHTMODEL_AMBIENT*_Brightness;
				UNITY_APPLY_FOG(i.fogCoord, col);
				return col;
			}
			ENDCG
		}
	}
	
	FallBack "Diffuse"
}
